-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
helper/schema: Do not collapse TypeSet hash values when configuration block contains only Computed attributes #197
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the bug fix - this is much cleaner than workarounds proposed in the linked PRs. 😄
The only thing I'd be slightly worried about is where the HashResource
function is used and in what context. e.g. We would not want spurious diffs to appear when a hash of a set item changes because a computed value has changed.
For that reason I'd like to double check with @hashicorp/terraform-core 👇
Can we be reasonably sure that the serialization logic is only used to guarantee uniqueness and not for diffing? I looked briefly at Set.HashEqual
and Set.Equal
, but I could not really trace the code using this + I reckon schema.HashResource
can be used by providers themselves, which leaves me unsure and a bit confused.
@bflad If we get the 2nd 👍 I'd like to run all (or majority) of AWS acceptance tests with this patched SDK and check for any anomalies, due to the (perceived) sensitivity of this part of the codebase.
If we see no anomalies caused by this patch then I'm happy to merge it.
Unfortunately I think this is one of those things where the answer differs depending on whether we're talking protocol version 4 or 5. In protocol version 4 (and thus Terraform 0.10/0.11), Terraform Core has no awareness of the idea of a set at all and just sees this as a flat map of key/value pairs. However, working in our favor is that Terraform 0.10 and 0.11 generally just trust entirely whatever diff is produced by the provider, because in protocol 4 the response is the diff. Therefore, as long as the provider (or rather, the SDK) is consistent with itself in how it interprets the prior state, this could be fine. I believe the legacy diffing logic uses the values for diffing and ignores the hash segments in the keys, but I'm not 100% sure so it'd be good to test it. In protocol version 5, the result of There were some particularly messy cases when we were working through the shim behaviors during 0.12 development that I think we should be careful to test the behaviors of here:
|
@bflad Do you mind adding tests for the 3 cases Martin mentioned above? Alternatively you can leave it to me. Assuming these tests are all passing and don't "uncover any skeletons" 😄 I would then continue by running AWS acceptance tests and ideally one more major provider, and if these pass then I'm happy to merge it. |
…ltiple subnets, sub-allocated pools and rate limits (#401) This is a list of things it brings: * Deprecates existing `external_networks` list of networks in favor of new `external_network` block which allows to specify one or more subnets inside the network and suballocate IPs from those ranges. Also deprecates `default_gateway_network` field. *Note*: as far as I tested all `external_network` block features work with simple edge gateway as well * Adds additional `external_network_ips` computed field to get all IP addresses set on uplink gateway interfaces (in addition to default IP in `default_external_network_ip` field) * Adds additional test `TestAccVcdEdgeGatewayParallelCreation` which aims to catch a reported error when two edge gateways are being attached to the same external network at the same time (so far I did not reproduce the error) * Removed a limitation where field `distributed_routing` was not read due to older API version not returning it. * Adds new field `fips_mode_enabled` to enable FIPS mode (it must be enabled by vCD administrator in general settings to make it work, otherwise returns a human readable error). **Note** FIPS mode field is not being returned from API therefore it _does not support read_ * Adds support for rate limiting per "external network" **Note**: It does not yet support update. **Important**. There is one problem with data sources which should be solved by this PR hashicorp/terraform-plugin-sdk#197 but is not yet done. _The problem_ is that when a `TypeSet` contains only computed variables and there are multiple blocks, **only one** is stored. This situation is documented and tested in existing `TestAccVcdEdgeGatewayExternalNetworks` test
Its probably safest to just merge this to v2, not sure the impact of merging to v1, do either of you @bflad / @radeksimko have thoughts on that? |
@paultyng I think the AWS Provider folks are fine with this being in v2, since we will need to run the full testing anyways just to be safe. |
👍 |
… block contains only Computed attributes Reference: hashicorp/terraform-provider-aws#7198 Reference: hashicorp/terraform-provider-aws#10045 Reference: hashicorp/terraform-provider-aws#10339 Reference: hashicorp/terraform#22719 When a resource schema contains the following: ```go "config_block_attribute": { Type: schema.TypeSet, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "attribute1": { Type: schema.TypeBool, Computed: true, }, "attribute2": { Type: schema.TypeString, Computed: true, }, }, }, }, ``` The TypeSet hash values were previously all collapsed to the zero-value, which meant that multiple set entries were lost. Here we check that all of the attributes are not just `Computed: true`. If they are all `Computed: true` attributes, ignore the check for user-defined attributes to compute the hash value.
7780a0b
to
5de5396
Compare
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Reference: hashicorp/terraform-provider-aws#7198
Reference: hashicorp/terraform-provider-aws#10045
Reference: hashicorp/terraform-provider-aws#10339
Reference: hashicorp/terraform#22719
When a resource schema contains the following:
The TypeSet hash values were previously all collapsed to the zero-value, which meant that multiple set entries were lost. Here we check that all of the attributes are not just
Computed: true
. If they are allComputed: true
attributes, ignore the check for user-defined attributes to compute the hash value.